package algorithms;

public class Fibonacci {
	
	static int fibonacci(int n) {
		if (n == 2) {
			return 2;
		}
		
		if (n == 1) {
			return 1;
		}
		
		if (n <= 0) {
			return 0;
		}
		
		return fibonacci(n - 1) + fibonacci(n - 2);
	}
	
	static int factorial(int n) {
		if (n <= 0) {
			return 1;
		}
		
		return n * factorial(n - 1);
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int n = 0;
		int i = 1;
		int sum = 0;
		while (n < 4000000) {
			n = fibonacci(i);
			if (n % 2 == 0) {
				sum += n;
			}
			i++;
		}
		System.out.println(sum);
		System.out.println(fibonacci(10));
	}
	
}
